﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace UniumLocalNetGames.Net
{
    public static class UniumLocalMessages
    {
        public static string InviteMessage
        {
            get 
            {
                return "UniumChatMessage";
            }
        }

        public static UniumLocalMessage CheckMessage(string data)
        {
            UniumLocalMessage mes = new UniumLocalMessage();
            switch (data[0])
            {
                case '0':
                    mes.type = MessagesEnum.Hello;
                    mes.text = data.Substring(1);
                    return mes;
                case '1':
                    mes.type = MessagesEnum.HelloAnswer;
                    mes.text = data.Substring(1);
                    return mes;
                case '2':
                    mes.type = MessagesEnum.Text;
                    mes.text = data.Substring(1);
                    return mes;
                case '3':
                    mes.type = MessagesEnum.Text;
                    mes.text = data.Substring(1);
                    return mes;
                default:
                    return null;
            }
        }
    }
    
    public class UniumLocalMessage
    {
        public MessagesEnum type;
        public string text;
        public IPEndPoint sender;
    }

    public enum MessagesEnum
    {
        Hello,
        HelloAnswer,
        Text,
        PrivatText
    }
}
